package learning.directory.Work.排序.Ac;/**
 * Created by Administrator on 2021/2/23.
 */

/**
 * @author aichao
 * @date 2021/2/22
 */
public class InsertSortDay3 {
    public static void main(String[] args) {
        int[] insertArr = {49,38,65,97,23,22,76,1};
        InsertSort(insertArr);
    }
    public static void InsertSort(int[] arr){
        int len = arr.length;
        int insertNumber;
        for (int i = 1; i < len; i++) {
            insertNumber = arr[i];
            int j = i-1;
            while(j>=0&&arr[j]>insertNumber){
                arr[j+1]=arr[j];
                j--;
            }
            arr[j+1]=insertNumber;
        }
        for (int i : arr) {
            System.out.print(i+"\t");
        }
    }
}
